package com.egg.ylt.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.egg.ylt.R;
import com.egg.ylt.Utils.Constants;
import com.egg.ylt.Utils.CustomUtils;
import com.egg.ylt.Utils.DateUtils;
import com.egg.ylt.Utils.StatusBarUtil;
import com.egg.ylt.pojo.UpLoadFileEntity;
import com.egg.ylt.pojo.UserByidEntity;
import com.egg.ylt.presenter.impl.CenterPresenterImpl;
import com.egg.ylt.view.ICenterView;
import com.yonyou.framework.library.base.BaseActivity;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.common.utils.AppSharedPreferences;

import butterknife.BindView;
import butterknife.OnClick;

public class ACT_Wallet extends BaseActivity<CenterPresenterImpl> implements ICenterView {

    @BindView(R.id.include_iv_back)
    ImageView includeIvBack;
    @BindView(R.id.include_tv_title)
    TextView includeTvTitle;
    @BindView(R.id.include_tv_right)
    TextView includeTvRight;
    @BindView(R.id.include_rl_view)
    RelativeLayout includeRlView;
    @BindView(R.id.tv_balance)
    TextView tvBalance;
    @BindView(R.id.btn_go_pay)
    TextView btnGoPay;
    private AppSharedPreferences mSp;

    @Override
    protected void getBundleExtras(Bundle extras) {

    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.act_wallet;
    }

    @Override
    protected View getLoadingTargetView() {
        return null;
    }

    @Override
    protected void initViewsAndEvents() {

        StatusBarUtil.setStatusBarColor(this, R.color.ylt_whit);
        StatusBarUtil.StatusBarLightMode(this);
        CustomUtils.setImmersiveStatusBar(mContext, includeRlView);
        //设置title
        includeTvTitle.setText("钱包");
        //设置title right文字
        includeTvRight.setText("交易明细");

        mSp = new AppSharedPreferences(mContext);

        //请求用户金额
//        mPresenter.getUserInfo(Constants.TOKEN, Constants.USERID);
    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    @Override
    protected boolean isBindEventBusHere() {
        return false;
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return false;
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return null;
    }

    @Override
    protected boolean isApplyKitKatTranslucency() {
        return false;
    }

    @Override
    public void showBusinessError(ErrorBean error) {

    }

    @OnClick({R.id.include_iv_back, R.id.include_tv_right, R.id.btn_go_pay})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.include_iv_back://返回键
                finish();
                break;
            case R.id.include_tv_right://交易明细
                readyGo(ACT_TransactionDetail.class);
                break;
            case R.id.btn_go_pay:// 去充值
                readyGo(ACT_Recharge.class);
                break;
        }
    }

    @Override
    public void getUserInfo(UserByidEntity entity) {
        if (entity == null) {
            return;
        }
        //设置钱包余额
        tvBalance.setText("¥" + DateUtils.getFormattedMoney(entity.getTotalAmount()));

    }

    @Override
    public void onPostPhoto() {

    }

    @Override
    public void getImgUri(UpLoadFileEntity entity) {

    }

    @Override
    protected void onResume() {
        super.onResume();
        //请求用户金额
        if (mPresenter != null) {
            mPresenter.getUserInfo(Constants.TOKEN);
        }

    }
}
